#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;

int t;
int n, m;
string s[10];

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> t;
    while(t--) {
        cin >> n >> m;
        for (int i = 0; i < n; i++)
            cin >> s[i];

        vector<pii> robots;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (s[i][j] == 'R') {
                    robots.push_back({i, j});
                }
            }
        }

        bool ok = true;
        int size = robots.size();

        sort(robots.begin(), robots.end());
        for (int i = 1; i < size; i++) {
            if (robots[i].second < robots[0].second) ok = false;
        }
        puts(ok ? "YES" : "NO");
    }
    return 0;
}